/* ************************************************************************** 
 * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved.                *
 * This software is the confidential and proprietary information of         *
 * Founder. You shall not disclose such Confidential Information            *
 * and shall use it only in accordance with the terms of the agreements     *
 * you entered into with Founder.                                           *
 *                                                                          *
 ****************************************************************************/     

package edu.ncut.xiaonei.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import edu.ncut.xiaonei.model.Users;
import edu.ncut.xiaonei.service.UserService;

/**   
 *    
 * 项目名称：renren_0200   
 * 类名称：ProfileAction   
 * 类描述：   
 * 创建人：黄传聪   
 * 创建时间：20132013-2-19 下午03:32:07   
 * 修改人：黄传聪   
 * 修改时间：20132013-2-19 下午03:32:07   
 * 修改备注：   
 * @version    
 *    
 */
@Controller("profileAction")
@Scope("prototype")
public class ProfileAction extends ActionSupport implements ModelDriven{
	private Users user = new Users();
	private UserService userService ;
	private HttpServletRequest request = ServletActionContext.getRequest();
//	跳转到个人主页
	public String goHomePageUI(){
		
		return SUCCESS;
	}
	
	public String changeImage(){
//		跳转到上传图像页面
		return SUCCESS;
	}
	
//	真正实现上传图像
	public String uploadImage(){
//		得到当前用户的session
		Users user1 = (Users) request.getSession().getAttribute("user");
//		修改用户表的photo字段修改
		System.out.println(user.getFileContentType() + "*******" + user.getFileFileName());
		user1.setPhoto(user.getFileFileName());
		System.out.println(user1);
	System.out.println(userService.getClass().getName());
	System.out.println(user1.getId());
//		userService.update(user1);
	userService.update(user1);
//		图像上穿到服务器
		
		return null;
	}

	
	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public Object getModel() {
		// TODO Auto-generated method stub
		return user;
	}

	public UserService getUserService() {
		return userService;
	}
	@Resource(name="userService")
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	
}
